// 1、字符串文字类型
let testString = 'Hello World'
testString = 'kk'

const constantString = 'Hello World'

// constantString = ''

let x: 'hello' = 'hello'
// x = 'world'

function printText(s: string, args: 'left' | 'right' | 'center') { }

printText('hello', 'center')
// printText('hello', 'center1')

// 2、数字文字类型
function compare(a: string, b: string): -1 | 0 | 1 {
  return a === b ? 0 : a > b ? 1 : -1
}

interface Options {
  width: number
}

function configure(x: Options | 'auto') {

}

configure({
  width: 100
})

configure('auto')

// 3、布尔文字类型
let b1: true = true
let b2: false = false

const obj_literal = {
  count: 0
}

if (true) {
  obj_literal.count = 1
}

function handleRequest(url: string, method: 'GET' | 'POST' | 'GUESS') { }

const req = {
  url: 'https://example.com',
  method: 'GET'
} as const

// as const 直接固定类型

//  as 'GET' 断言确定类型
// handleRequest(req.url, req.method as 'GET')
handleRequest(req.url, req.method)
